package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 86135
 * Date: 2023-04-02
 * Time: 21:34
 */
public class FindOperation  implements  IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书!!");
        Scanner scanner = new Scanner(System.in);
        int currentSize = bookList.getUsedSize();
        System.out.println("请输入你要查找的图书的书名");

        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            String name = scanner.nextLine();//名字
            if(book.getName().equals(name)){
                System.out.println("找到这本书了！");
                System.out.println(book);
                System.out.println();
                return;
            }
        }
        System.out.println("没有你要查找的这本书！！！");

    }
}
